package chat.logic;

import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * @time Oct 28, 2009, 20:50:17 PM
 * @author fdcube
 * @version FreeChat-Server v1.1.2
 */
public class CheckOl extends TimerTask {

    public static final JSONObject UserStatus = new JSONObject();

    @Override
    public void run() {
        try {
            System.out.println("User Remover Checker Runned");
            if (UserStatus.length() > 0 && User.UserList.length() > 0) {
                JSONArray jsaTmp = User.UserList.names();
                for (int i = 0; i < jsaTmp.length(); i++) {
                    if (!UserStatus.has(jsaTmp.getString(i))) {
                        User.RemoveUser(jsaTmp.getString(i));
                        System.out.println(jsaTmp.getString(i) + "  Time Out, Kicked.");
                    } else {
                        UserStatus.remove(jsaTmp.getString(i));
                    }
                }
            }
        } catch (JSONException ex) {
            Logger.getLogger(CheckOl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
